{extend name="public:base" /}

{block name="content"}
<div class="back_btn">
    <!-- 返回按钮 -->
    <button class="btn btn_color" type="button" style="outline: none;">
        <a href="{:url('index/index')}"><span class="glyphicon glyphicon-arrow-left" style="color:#3c8dbc;font-size: 18px;"></span></a>
    </button>
</div>
<div class="row_box">
    <div class="col_box">
        <div class="box-header" data-original-title="" style="height: 30px;">
            <span><i class="glyphicon glyphicon-plus"></i>微信推送</span>
        </div>
        <div class="input_box">
            <form action="" id="commentForm" method="post">
                <div class="form-group f_g_box">
                    <label>订单ID:</label>
                    <input  type="hidden" name="id" value="{$info.id}">
                    <input type="text" class="form-control" name="name" id="name" value="{$info.id}" disabled>
                </div>
                <div class="tishi"><label>&nbsp;&nbsp;</label><input type="hidden"></div>
                <div class="form-group f_g_box">
                    <label>顾客姓名:</label>
                    <input type="text" class="form-control"  id="maphone" value="{$info.name}" disabled>
                </div>
                <div class="tishi"><label>&nbsp;&nbsp;</label><input type="hidden"></div>
                <div class="form-group f_g_box">
                    <label>业务状态</label>
                    <select class="form-control" name="ywstate" lay-verify="required" id="ywstate">
                        {eq name='yaoyue' value='1'}<!--预约成功-->
                        {volist name='state' id='data'}
                        <option value="{$data.id}" {neq name='data.id' value='5'}disabled{/neq}  >{$data.name}</option>
                        {/volist}
                        {else/}<!--意向客资-->
                        {volist name='state' id='data'}
                        <option value="{$data.id}" {neq name='data.id' value='7'}disabled{/neq}  >{$data.name}</option>
                        {/volist}
                        {/eq}
                    </select>
                </div>
                <div class="tishi"><label>&nbsp;&nbsp;</label><input type="hidden"></div>

                <div class="form-group f_g_box" id="yyshow"  style="display: none;">
                    <label>预约场馆:</label>
                    <select class="form-control" name="yycg" id="yycg">
                        <option value="">请选择</option>
                        {volist name='yycg' id='data'}
                        <option value="{$data.id}" {eq name="info['yycg']" value="$data.id"}selected="selected"{/eq} >{$data.title}</option>
                        {/volist}
                    </select>
                </div>
                <div class="tishi"><label>&nbsp;&nbsp;</label><input type="hidden"></div>

                <div class="form-group f_g_box" id="yshow"   style="display: none;">
                    <label>预约拍摄时间:</label>
                    <input type="text" name="yypstime" id="yypstime"  onclick="laydate({min: laydate.now(),istime: true,format: 'YYYY-MM-DD hh:mm'})" {neq name="info.yypstime" value="1970-01-01 8:00"}value="{$info.yypstime}"{/neq}>
                </div>
                <div class="tishi"><label>&nbsp;&nbsp;</label><input type="hidden"></div>

                <div class="form-group f_g_box">
                    <label>备注</label>
                    <textarea type="text" rows="3"  name="bz">{neq name='bz' value='0'}{$bz}{/neq}</textarea>
                </div>
                <div class="tishi"><label>&nbsp;&nbsp;</label><input type="hidden"></div>
                <div class="btn_t">
                    <button>确定推送</button>
                </div>
            </form>
        </div>
    </div>
</div>
<input type="hidden" class="depar_id" value="{$Think.session.admin_user.depar_id}"></div>
<!-- 搜索 结束 -->
<!-- 列表 -->
{/block}

{block name="js"}

<script type="text/javascript" src="__JS__/jquery-3.2.0.min.js"></script>
<script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
<script type="text/javascript" src="__JS__/index.js"></script>
<script type="text/javascript" src="__STATIC__/validate/jquery.validate.min.js"></script>
<script type="text/javascript" src="__STATIC__/validate/jquery.metadata.js"></script>
<script type="text/javascript" src="__STATIC__/laydate/laydate.js"></script>
<script type="text/javascript" src="__STATIC__/layer/layer.js"></script>
<script type="text/javascript" src="__JS__/calendar.js"></script>
<script type="text/javascript">

    $().ready(function() {
        $("#ywstate").change(function () {
            var ywstate=$('#ywstate').val();
            var d_par=$('.depar_id').val();
            if(ywstate==5 ){
                document.getElementById('yshow').style.display = "";
                document.getElementById('yyshow').style.display = "";
            }
        });
        var d_par=$('.depar_id').val();
        if(d_par==3){
            $('#yshow').show();
            $('#yyshow').show();
            $("#yycg").attr('required','required');
            $("#yypstime").attr('required','required');
        }

        // 在键盘按下并释放及提交后验证提交表单
        $("#commentForm").validate({

            rules: {
                ywstate:{required:true},
                bz:{required:true},
             },
             messages: {
                 ywstate:"请选择业务状态！",
                 yycg:"请选择拍摄场馆！",
                 yypstime:"请填写邀约拍摄时间",
                 bz:"请填写备注！",
             },

            errorPlacement: function(error, element) {
                if (element.is(":input"))
                    error.appendTo(element.parent().next());
            },
            submitHandler: function(form)
            {
                $.ajax({
                    type: "POST",
                    url:  "{:url('weixin')}",
                    data: $(form).serialize(),
                    beforeSend:function(){
                        $('#submit').attr("disabled","false"); //禁止点击
                    },
                    success: function(msg){
                        if( msg.status==1 ){
                            $('#submit').attr("disabled","false"); //禁止点击
                            layer.msg(msg.msg, {icon: 1});
                            setTimeout(function(){
                                location.href="{:url('index/listing')}";
                            },3000); //延迟演示
                        }else if( msg.status==2 ){
                            layer.msg(msg.msg, {icon: 2});
                            setTimeout(function(){
                                location.href=msg.url;
                            },3000); //延迟演示
                        }else{
                            layer.msg(msg.msg, {icon: 2});
                            $('#submit').removeAttr("disabled"); //禁止点击
                        }
                    }
                });
            }

        });
        return false;
    });
</script>
{/block}

